<!--Generate by Kevin's CodeBuilder -->
<!--请注意！这里是页面片段，定义的标签ID，js变量不要与index.html列表页面重复-->
<!--如果是较复杂的页面，可以修改window的数据类型(dataType: iframe),然后将form.html改为完整的页面,实现iframe隔离，需要修改curdObj的访问方式为parent.curdObj-->
<div id="form_container" class="form_container">
    <!--利用隐藏的id标签区分是新增/编辑-->
    <input type="hidden" id="id" name="id" th:value="*{id}"/>
    <input type="hidden" id="pid" name="pid" th:value="*{pid}"/>
    <input type="hidden" id="old_menuText" name="old_menuText" value=""/>
    <table class="k_form_table">
        <tr>
            <td class="label label30">[(${Lang.menu_menuText})]</td>
            <td>
                <input id="menuText" name="menuText" class="form_input form_input50" type="text"/>
            </td>
        </tr>
        <tr>
            <td class="label label30">[(${Lang.menu_menuIconCss})]</td>
            <td>
                <input id="menuIconCss" name="menuIconCss" class="form_input form_input50" type="text"/>
            </td>
        </tr>
        <tr>
            <td class="label label30">[(${Lang.menu_isLeaf})]</td>
            <td>
                <label class="k_radio_label k_radio_anim">
                    <input type="radio" name="isLeaf" value="1" />
                    <i class="k_radio_i"></i>[(${Lang.common_yes})]
                </label>
                <label class="k_radio_label k_radio_anim">
                    <input type="radio" name="isLeaf" value="0"/>
                    <i class="k_radio_i"></i>[(${Lang.common_no})]
                </label>
            </td>
        </tr>
        <tr>
            <td class="label label30">[(${Lang.menu_isEnable})]</td>
            <td>
                <label class="k_radio_label k_radio_anim">
                    <input type="radio" name="isEnable" checked="checked" value="1"/>
                    <i class="k_radio_i"></i>[(${Lang.common_yes})]
                </label>
                <label class="k_radio_label k_radio_anim">
                    <input type="radio" name="isEnable" value="0"/>
                    <i class="k_radio_i"></i>[(${Lang.common_no})]
                </label>
            </td>
        </tr>
        <tr>
            <td class="label label30">[(${Lang.menu_isVisible})]</td>
            <td>
                <label class="k_radio_label k_radio_anim">
                    <input type="radio" name="isVisible" value="1" checked="checked"/>
                    <i class="k_radio_i"></i>[(${Lang.common_yes})]
                </label>
                <label class="k_radio_label k_radio_anim">
                    <input type="radio" name="isVisible" value="0"/>
                    <i class="k_radio_i"></i>[(${Lang.common_no})]
                </label>
            </td>
        </tr>
        <tr>
            <td class="label label30">[(${Lang.menu_controller})]</td>
            <td>
                <input id="controller" name="controller" class="form_input form_input50" type="text"/>
            </td>
        </tr>
        <tr>
            <td class="label label30">[(${Lang.menu_pageName})]</td>
            <td>
                <input id="pageName" name="pageName" class="form_input form_input50" type="text"/>
            </td>
        </tr>
        <tr>
            <td class="label label30">[(${Lang.menu_params})]</td>
            <td>
                <input placeholder="p1=1&p2=2" id="params" name="params" class="form_input form_input50" type="text"/>
            </td>
        </tr>
        <tr>
            <td class="label label30">[(${Lang.menu_orderIndex})]</td>
            <td>
                <input id="orderIndex" name="orderIndex" value="1" class="form_input form_input50" type="text"/>
            </td>
        </tr>
        <tr>
            <td class="button_td" colspan="2" style="padding-top:15px">
                <button id="button_submit" class="k_common_button"><i class="fa fa-floppy"></i> <span>[(${Lang.common_save})]</span>
                </button>
                <button id="button_goback" class="k_common_button"><i class="fa fa-reply-all"></i>
                   <span>[(${Lang.common_goback})]</span>
                </button>
            </td>
        </tr>
    </table>
</div>
<script type="application/javascript" th:src="@{/static/lib/vue.min.js}"></script>
<script type="application/javascript" th:inline="javascript">

    $B.DomUtils.onDomLoaded(function () {
        var vueForm,
            entityJson = [(${entityJson})],
            $form = document.getElementById("form_container"),
            idValue = document.getElementById("id").value;  //用于区分新增,编辑

        var  pid = document.getElementById("pid").value;
        var tags = $B.DomUtils.findByTagName($form, "input[name=isLeaf]");
        for (var i = 0; i < tags.length; i++) {
            let $leaf = tags[i];
            if (pid === "0" || $leaf.value === "0") {
                $B.DomUtils.attribute($leaf, {"checked": true});
            } else {
                $B.DomUtils.attribute($leaf, {"checked": false});
            }
        }
        /***定义验证字段 ，配置监听回调等***/
        var formOpt = {
            verifyOnChange: true,
            verify: {
                "menuText": ['require', 'char']
            }
        };
        /**自定义控件配置***/
        var diyCtls = {} ;
        vueForm = $B.vueForm( $form,entityJson,diyCtls,formOpt);

        /***当窗口关闭时候，销毁form**/
        curdObj.setVueForm(vueForm);

        /**绑定事件**/
        $B.DomUtils.click(document.getElementById("button_goback"), function () {
            curdObj.closeWindow();
        });
        $B.DomUtils.click(document.getElementById("button_submit"), function () {
            if(vueForm.toVerify()){
                var prs = vueForm.toJSON();
                if(idValue === ""){
                    curdObj.add(prs,this);
                }else{
                    curdObj.update(prs,this);
                }
            }else{
                $B.error("[(${Lang.common_verify_err})]",1.5);
            }
        });
    });
</script>
